package com.lbb.waimai.controller;

import com.lbb.waimai.entiry.Food;
import com.lbb.waimai.result.R;
import com.lbb.waimai.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/food")
public class FoodController {
    @Autowired
    private FoodService foodService;


    //根据菜品分类获取菜单列表
    @GetMapping("/getFoodListByCategoryId")
    public R  getFoodListByCategoryId(@RequestParam  Integer id){
       List<Food> foodList = foodService.getFoodListByCategoryId(id);
        return R.ok().data("data",foodList);
    }

    //根据菜品id查询详细
    @GetMapping("getFood")
    public R getFood(@RequestParam Integer id){
        foodService.getById(id);
        return R.ok();
    }
}
